#ifndef CLIENT_SOCKET_H
#define CLIENT_SOCKET_H

#include <QQueue>
#include <QTcpSocket>

#include "Structs.h"

class ClientSocket : public QObject
{
    Q_OBJECT
    public:
        ClientSocket(QTcpSocket* sock);

    public slots:
        void phaseChanged(PHASE phase, int Player);
        void playerInfos(PlayerInfos infos);
        void stateInfos(StateInfos infos);
        void allStatesInfos(QList<StateInfos> infos);
        void allPlayersInfos(QList<PlayerInfos> infos);
        void error(ERROR_CODE err, QStringList arg = QStringList());
        void info(INFOS_CODE inf, QStringList arg = QStringList());
        void requestDiceRoll(bool defensor);
        void playerDefeated(quint32 ID);
        void gameStarted(quint32 nbr);

        void changeLobbyState(bool ready);

    private slots:
        void dataReceived();
        void send();

    signals:
        void requestNextPhase();
        void requestUpdate();
        void requestPlayerInfos(quint32 player);
        void requestStateInfos(QString state);
        void requestMovement(QString from, QString to, quint16 nbr);
        void requestAttack(QString from, QString to, quint16 nbr, bool a);
        void requestReinforcement(QString state, quint16 nbr);
        void requestChangeLobbyState();

    private:
        QQueue <Data*> m_toSend;
        QTcpSocket *m_socket;
        quint32 m_size;
};

#endif
